$(document).ready(function() {
	// $('.detail').click(function(e) {
	// 	e.preventDefault();
	// 	ShowDetail(this);
	// });
	
	// $('#station-names-json').change(function() {
	// 	LoadStationJson();
    // });
	
	$('#enable-edit-veh-info').click(function() {
		Veh_EnableEdit();
	});

	
	//LoadStationJson();
});

function Veh_EnableEdit() {
	var form1 = document.getElementById("update-detail");

	var el = form1.getElementsByTagName("input");

	for (var i=0; i< el.length; i++){
		el[i].disabled = false;
	}

	var send = document.getElementById("send-veh-edit");
	send.disabled = false;

}

function Veh_DeleteItem(id) {

	//alert(id)

	bootbox.confirm("注意！删除后该车相关的资料将全部丢失。您确定要删除吗？", function(result) {
		if (result) {
			window.location.href="/delete?objectid="+ id+"&backurl="+window.location.href;  
		} 
	});
	
}

function Standard_Callback() {
    try {
        alert(this.ResultString);
    }

    catch (e) {   
        alert(e);
    }
}

function Standard_ValidationCallback() {
    try {
        alert(this.ResultString);
    }

    catch (e) {   
        alert(e);
    }
}

function Standard_ErrorCallback() {
    try {
        alert(this.ResultString);
    }

    catch (e) {   
        alert(e);
    }
}

function ShowDetail(result) {
	try {
		var postData = {};
		postData["stationId"] = $(result).attr('data');
		
        var service = new ServiceResult();
        service.getJSONData("/buoy/retrievestation",
                            postData,
                            ShowDetail_Callback,
                            Standard_ValidationCallback,
                            Standard_ErrorCallback
                            );
    }

    catch (e) {
        alert(e);
    }
}

function ShowDetail_Callback() {
	try {
		$('#system-modal-title').html("Buoy Details");
		$('#system-modal-content').html(this.ResultObject);
		$("#systemModal").modal('show');
	}
	
	catch (e) {
        alert(e);
    }
}

// function LoadStationJson() {
// 	try {
// 		$('#stations-view').html('Loading View, Please Wait...');
		
// 		url = "/buoy/station/" + $('#station-names-json').val();
		
// 		var postData = {};

// 		var service = new ServiceResult();
//         service.getJSONDataRaw(url,
//                             postData,
//                             LoadStationJson_Callback
//                             );
//     }

//     catch (e) {
//         alert(e);
//     }
// }

// function LoadStationJson_Callback() {
// 	try {
// 		$('#stations-view-json').html(JSON.stringify(this.Data));
// 	}
	
// 	catch (e) {
//         alert(e);
//     }
// }

// function LoadStationJsonOwnTab() {
// 	url = "/buoy/station/" + $('#station-names-json').val();
// 	window.open(url);
// }
